package js.dwim.client.dialogs;

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class SplashScreen
        extends JFrame
{
    private static final long serialVersionUID = 1L;
    private final JPanel      contentPanel     = new JPanel();

    /**
     * Create the dialog.
     */
    public SplashScreen()
    {
        setTitle( "Connecting to server" );
        setBounds( 100, 100, 450, 160 );
        getContentPane().setLayout( new BorderLayout() );
        contentPanel.setLayout( new FlowLayout() );
        contentPanel.setBorder( new EmptyBorder( 5, 5, 5, 5 ) );
        getContentPane().add( contentPanel, BorderLayout.CENTER );

        JLabel lblInfo = new JLabel( "Establishing connection with server ..." );
        lblInfo.setHorizontalAlignment( SwingConstants.CENTER );
        contentPanel.add( lblInfo );

        JPanel buttonPane = new JPanel();
        buttonPane.setLayout( new FlowLayout( FlowLayout.RIGHT ) );
        getContentPane().add( buttonPane, BorderLayout.SOUTH );
        {
            JButton cancelButton = new JButton( "Cancel" );
            cancelButton.addActionListener( new ActionListener() {
                public void actionPerformed( ActionEvent arg0 )
                {
                    Runtime.getRuntime().exit( 0 );
                }
            } );
            cancelButton.setActionCommand( "Cancel" );
            buttonPane.add( cancelButton );
        }
        setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE );
    }

}
